package com.itlong.cloud.iot.service.server.impl;

import com.itlong.cloud.POJO.VO.common.ProjectIotInfo;
import com.itlong.cloud.iot.dao.IotInteriorDao;
import com.itlong.cloud.iot.service.server.IotInteriorService;
import com.itlong.cloud.utils.words.StringHandlerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <desc>
 *      iot内部业务接口实现类
 * </desc>
 *
 * @createDate 2020/01/08
 */
@Service
public class IotInteriorServiceImpl implements IotInteriorService{

    @Autowired
    IotInteriorDao iotInteriorDao;

    /**
     * <desc>
     *      根据设备序列号获取iot信息
     * </desc>
     *
     * @return
     * @author Jiaqi.X
     * @createDate 2020/01/08
     */
    @Override
    public ProjectIotInfo getIotInfoByDeviceUnique(String deviceUnique) {
        ProjectIotInfo projectIotInfo = iotInteriorDao.getProjectIotInfoByProjectId(StringHandlerUtil.getProjectIdByDeviceUnique(deviceUnique),
                StringHandlerUtil.getDeviceTypeByDeviceUnique(deviceUnique),deviceUnique);
        projectIotInfo.setIotInfos(iotInteriorDao.getIotInfosByIotType(projectIotInfo.getIotFlag(),StringHandlerUtil.getDeviceTypeByDeviceUnique(deviceUnique)));
        return projectIotInfo;
    }
}